home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Leonardo the Inventor
/
Leonardo The Inventor (93026)(Broderbund)(Riverdeep)(2004).iso
/
LEOWINMV
/
DATABASE.DIR
/
00107_Script_CHECK DATABASE - INDEX
< prev
next >
Wrap
Text File
|
1996-03-28
|
3KB
|
75 lines
-- --------------------------------------------------------------
-- Handler checkIndex checks all the search results in the index
-- fields and puts the errors in the appropriate "Index Errors"
-- field ("A INDEX ERRORS", "B INDEX ERRORS", ...)
on checkIndex firstCast, lastCast
initalizeEquivalentTerms
emptyIndexErrorFields
set oldIndexLetter = char 1 of the name of cast firstCast
set errorFieldName = oldIndexLetter && "INDEX ERRORS"
-- go through the index casts one by one
repeat with curIndex = firstCast to lastCast
set castName = the name of cast curIndex
put "checking" && castName
set indexLetter = char 1 of castName
if (indexLetter <> oldIndexLetter) then -- new letter
set errorFieldName = indexLetter && "INDEX ERRORS"
set oldIndexLetter = indexLetter
end if
set indexText = field curIndex
set numLines = the number of lines in indexText
-- go through the lines one by one
repeat with curLine = 1 to numLines
set lineText = line curLine of indexText
if (char 1 of lineText = "*") then -- new entry
set curEntry = char 2 to length(lineText) of lineText
put "checking entry" && curEntry
else
set searchResult = the number of cast (lineText && "TEXT1")
if (searchResult = -1) then
-- check if an equivalent term exists
set equivTerm = getEquivalentTerm(searchResult)
if (equivTerm = -1) then
-- index error
put curEntry & ":" & lineText & RETURN after field errorFieldName
end if -- equivTerm = -1
end if -- searchResult = -1
end if -- new Entry
end repeat -- going through the lines
put "finished checking" && castName
end repeat -- going through the casts
end
-- --------------------------------------------------------------
-- Handler emptyIndexErrorFields resets the index error fields for
-- the new generation of index errors.
on emptyIndexErrorFields
repeat with indexLetter = 65 to 90 -- "A" to "Z"
set indexFieldName = numToChar(indexLetter) && "INDEX ERRORS"
put EMPTY into field indexFieldName
end repeat
end
on checkIndexForDuplicates firstCast, lastCast
put empty into field "indexEntries"
repeat with curIndex = firstCast to lastCast
set curIndexEntries = field curIndex
set numLines = the number of lines in curIndexEntries
repeat with curLine = 1 to numLines
if (char 1 of line curLine of curIndexEntries = "*") then
put line curline of curIndexEntries
put line curLine of curIndexEntries & RETURN after field "indexEntries"
end if
end repeat
end repeat
end